package com.njym.java.security.admin.rest;

import com.github.pagehelper.PageInfo;
import com.njym.java.security.admin.biz.InvestGroupBiz;
import com.njym.java.security.admin.entity.InvestGroup;
import com.njym.java.security.common.msg.ObjectRestResponse;
import com.njym.java.security.common.rest.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("investGroup")
public class InvestGroupController extends BaseController<InvestGroupBiz, InvestGroup> {

    /**
     * 问卷分组信息
     * @param name
     * @param limit
     * @param page
     * @return
     */
    @RequestMapping(value = "/queryInvestGroup",method = RequestMethod.GET)
    @ResponseBody
    public ObjectRestResponse<InvestGroup> list(
            String name,
            @RequestParam(defaultValue = "10") int limit,
            @RequestParam(defaultValue = "1")int page){

        List<InvestGroup> list = baseBiz.getInvestGroup(page,limit,name);
        long total = PageInfo.of(list).getTotal();
        Map<String, Object> data = new HashMap<>(2);
        data.put("list", list);
        data.put("total", total);

        return new ObjectRestResponse<InvestGroup>().rel(true).data(data);
    }

}